﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Manager_EditSignTable3 : System.Web.UI.PageEx
{
    private DataSet ds = null;
    public static int iSelectId = 0;
    private string strPageCode = "B0023";
    private string strLoginResult = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!DalEx.DbManagerEx.CheckLoginRight(UserType, UserId, strPageCode, ref strLoginResult))
        {
            FineUI.Alert.Show(strLoginResult, FineUI.MessageBoxIcon.Warning);
            Response.Redirect("Login.aspx");
        }
        int.TryParse(Convert.ToString(Request.QueryString["Id"]), out iSelectId);
        if (!Page.IsPostBack)
        {
            DataBinds();
        }
    }
    private void DataBinds()
    {
        Model.BaoMing3 M_BaoMing = Dal.BaoMing3Dal.Select(iSelectId);
        if (M_BaoMing != null)
        {
            hfSelectId.Value = iSelectId.ToString();
            labActivityDate.Text = M_BaoMing.ActivityDate.ToString("yyyy-MM-dd");
            labActivityName.Text = M_BaoMing.ActivityName;
            labActivityOrg.Text = M_BaoMing.ActivityOrg;
            labLimitNums.Text = M_BaoMing.LimitNums.ToString();
            txtBabyClass.Text = M_BaoMing.BabyClass;
            txtBabyName.Text = M_BaoMing.BabyName;
            txtParentName.Text = M_BaoMing.ParentName;
            txtMobile.Text = M_BaoMing.Mobile;
        }

    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string strOrderSN = WebBase.Comm.GetOrderNo("ZC");
        string strActivityName = SqlHelper.String(labActivityName.Text);
        string strActivityDate = SqlHelper.String(labActivityDate.Text);
        string strActivityOrg = SqlHelper.String(labActivityOrg.Text);
        int intLimitNums = 0;
        int.TryParse(labLimitNums.Text, out intLimitNums);
        string strBabyClass = SqlHelper.String(txtBabyClass.Text);
        string strBabyName = SqlHelper.String(txtBabyName.Text);
        string strParentName = SqlHelper.String(txtParentName.Text);
        string strMobile = SqlHelper.String(txtMobile.Text);
        if (strBabyClass.Length > 50)
        {
            MessageBox("幼儿班级不能超过50个字！");
            return;
        }
        if (strBabyName.Length > 50)
        {
            MessageBox("幼儿姓名不能超过50个字！");
            return;
        }
        if (strParentName.Length > 100)
        {
            MessageBox("幼儿姓名不能超过100个字！");
            return;
        }
        if (strMobile.Length > 50)
        {
            MessageBox("联系电话不能超过50个字！");
            return;
        }
        Model.BaoMing3 M_BaoMing = new Model.BaoMing3();
        int.TryParse(hfSelectId.Value, out iSelectId);
        M_BaoMing.Id = iSelectId;
        M_BaoMing.OrderNO = strOrderSN;
        M_BaoMing.ActivityDate = Convert.ToDateTime(strActivityDate);
        M_BaoMing.ActivityID = iSelectId;
        M_BaoMing.ActivityName = strActivityName;
        M_BaoMing.ActivityOrg = strActivityOrg;
        M_BaoMing.LimitNums = intLimitNums;
        M_BaoMing.BabyClass = strBabyClass;
        M_BaoMing.BabyName = strBabyName;
        M_BaoMing.ParentName = strParentName;
        M_BaoMing.Mobile = strMobile;
        M_BaoMing.Status = 0;
        M_BaoMing.Notes = "";
        M_BaoMing.Checkinfos = "";

        int iResult = 0;
        string strResult = string.Empty;
        iResult = DalEx.BaoMing3Ex.Insert(M_BaoMing, ref strResult);
        if (iResult > 0)
        {
            FineUI.Alert.Show(strResult,FineUI.MessageBoxIcon.Information);
        }
        else
        {
            FineUI.Alert.Show(strResult, FineUI.MessageBoxIcon.Warning);
        }
    }
}
